<!-- 任务执行情况 -->
<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>陪餐模式</span>
        <span class="el-icon-circle-close close-Btn-line" @click="checkVideoStatus"></span>
      </div>
      <div class="commentBody">
        <div class="foodModle-body">
          <div class="foodModle-list" :class="{activebtn:foodModel==item}" v-for="item in 2" :key="item" @click="foodModel=item">
            <div class="foodModle-title">模式{{ item }}{{`${oldModle==item?'（当前模式）':''}`}}</div>
<!--            <img src="@/assets/imageAdmin/foodModle1.png" alt="">-->
            <el-image
                style="width: 300px; height: 200px"
                :src="srcList[item-1]"
                :preview-src-list="srcList">
            </el-image>
          </div>
        </div>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click.native="checkVideoStatus" size="small">返回</el-button>
        <el-button @click.native="saveSubmitModle" v-if="dialogVisible && foodModel!==oldModle" size="small" plain type="primary">确认并保存</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import {templateEdit, templateDetail} from '@/api/admin/food.js'

export default {
  name: 'food',
  props: ['visible'],
  components: {},
  data() {
    return {
      dialogVisible: false,
      typelist: [],
      srcList: [
        '/docImg/model1.png',
        '/docImg/model2.png',
      ],
      foodModel: 0,
      oldModle: 0
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.getTypeListFn()
      } else {
        this.typelist = []
        this.foodModel = 0
      }
    }
  },
  created() {
  },
  methods: {
    getTypeListFn() {
      templateDetail({id:1}).then(res => {
        this.foodModel = res.vo.type
        this.oldModle = res.vo.type
      })
    },
    saveSubmitModle(){
      let that =this
      this.$confirm('确认切换当前陪餐模版, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        templateEdit({id:1, type: that.foodModel}).then(res=>{
          if(!res.code){
            this.$emit('getNewModle')
            this.$message.success(res.msg)
            this.checkVideoStatus()
          }else{
            this.$message.error(res.msg)
          }
        })
      }).catch(() => {
      });
    },
    // 关闭
    checkVideoStatus() {
      this.$emit('update:visible', false)
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 750px;
  height: 500px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.footer-release {
  padding: 20px 0 0;
  min-height: 400px;
}

.last-day-list-box {
  padding: 20px 0 0;
  max-height: 460px;
  overflow-y: auto;
}

.last-day-list-box-body {
  border: 1px solid #000;
  border-radius: 6px;
  cursor: pointer;
  width: 100px;
  float: left;
  margin-right: 20px;
  color: #333;
  margin-bottom: 20px;
  position: relative;
}

.last-day-list-box-body:hover {
  box-shadow: 0 0 14px #1b8de5;
}

.close-btn-foot {
  position: absolute;
  top: -15px;
  right: -15px;
  color: red;
  font-size: 30px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  margin: 0;
}

.last-day-list-box-img {
  width: 98px;
  height: 98px;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;

}

.last-day-list-box-title {
  text-align: center;
  color: #000;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foodList-box {
  max-height: 400px;
  overflow-y: auto;
}
.foodModle-body{
  display: flex;
  align-items: center;
  justify-content: center;
}
.foodModle-list{
  border:1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  box-sizing: border-box;
  text-align: center;
  cursor: pointer;
}
.foodModle-title{
  text-align: center;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: bold;
}
.foodModle-list img{
  width: 50%;
  display: block;
}
.foodModle-list:first-child{
  margin-right: 10px;
}
.foodModle-list.activebtn{
  border: 1px solid #ef6f14;
  box-shadow: 0 2px 6px #ef6f14;
}
</style>
